/*
 * Copyright (C) 2025 Tsingteng MicroSystem
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef _OSI_TYPES_H_
#define _OSI_TYPES_H_
#include <pthread.h>
#include <stdatomic.h>

#define OS_DEFAULT_THREAD_PRIO (0)
#define MUTEX_NAME_MAX_LEN  18
/** @brief 配置索引时的查找键值类型 */
#define tCF_KEY char*

#define OSI_MS_PER_SEC (1000)
#define OSI_NS_PER_MS  (1000000)
#define OSI_NS_PER_SEC (1000000000)

/** @brief 原子变量类型 */
typedef _Atomic(uint32_t) tATOMIC;

/** @brief 互斥锁类型 */
typedef struct {
    /** @brief 记录锁名称 */
    char name[MUTEX_NAME_MAX_LEN];
    /** @brief 是否已经初始化 */
    tATOMIC state;
    /** @brief 是否是可重入锁 */
    bool is_recursive;
    /** @brief 互斥锁 */
    pthread_mutex_t mutex;
    /** @brief 条件变量 */
    pthread_cond_t cond;
} tMUTEX;

/** @brief 线程句柄类型 */
typedef pthread_t tTHREAD;

#endif
